package com.zzl.springboot_mybatis_demo.util;

import com.zzl.springboot_mybatis_demo.entity.res.ResultVo;

/**
 * description: 响应结果工具类
 * @author 朱正磊
 * @date 2019-10-13 22:40:22
 */
@SuppressWarnings("ALL")
public class ResultVoUtil {

    public static ResultVo build(Integer code, String msg, Object data) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        resultVo.setData(data);
        return resultVo;
    }

    public static ResultVo success(Object data) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(200);
        resultVo.setMsg("SUCCESS");
        resultVo.setData(data);
        return resultVo;
    }

    public static ResultVo success() {
        return success(null);
    }

    public static ResultVo fail(Integer code, String msg) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        return resultVo;
    }

}
